<!doctype html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<title>钢链网-资源单</title>
	<link rel="stylesheet" href="/resource/css/gl_index.css">
	<link rel="stylesheet" href="/resource/css/gl_resource.css">
    <link rel="stylesheet" href="/resource/css/gl_showBo.css">
    <script src="/resource/js/gl_showBo.js"></script>
	<script src="/resource/js/jquery-1.11.3.min.js"></script>
	<script src="/resource/js/gl_index.js"></script>
    <script>
        $(function(){
            $('.down').click(function(){
                var product_id = $(this).attr("res_id");
                $.ajax({
                    url: "/down_new_resource",
                    type: "POST",
                    data: 'down_num=1&product_id='+product_id,
                    async:false,
                    success: function (msg) {

                    }
                });
            });
            //搜索AJAX


            $('.category').click(function(e){
                var category = $(this);
                var cate_id = $('#category').val();
                e?e.stopPropagation():event.cancelBubble = true;
                $.ajax({
                    url:'/ajax_new_resource',
                    type:'post',
                    data:'select_category='+cate_id,
                    success:function(data){console.log(data);
                        $.each(data,function(index,arr){
                            var str = "";
                            $.each(arr,function(i,a){
                                if(index == 'brand'){
                                    str += "<li rel="+ a.category_name+">"+a.brand_name+"</li>";
                                    $('[name="category"]').parents('.form-group').find('ul').html(str);
                                }
                                if(index == 'factory'){
                                    str += "<li rel="+ a.factory_id+">"+a.factory_name+"</li>";
                                    $('[name="factory"]').parents('.form-group').find('ul').html(str);
                                }
                            });
                        });
                    }
                });
                if(category.hasClass('open')){
                    category.removeClass('open').siblings('.category-cont').hide();
                }else{
                    $('.category-cont').hide();
                    $('.category').removeClass('open');
                    category.addClass('open').siblings('.category-cont').show();
                }
            });

            $('.category-cont').delegate('li','click',function(){
                var name = $(this).html();
                var i_d = $(this).attr('rel');
                $(this).parents('.form-group').find('.category-title').html(name);
                $(this).parents('.form-group').find('input').val(i_d);
                $('.category-cont').hide();
                $('.category').removeClass('open');
            });

            $('.category-cont').click(function(e){
                e?e.stopPropagation():event.cancelBubble = true;
            });

            $(document).click(function(){
                $('.category-cont').hide();
                $('.category').removeClass('open');
            });
        });
    </script>
</head>
<body>
@include('common.shop_head')

<div class="resource main">
        <div class="res-bg res-conf">
            <dl class="first">
                <dt>城市：</dt>
                <dd>
                    @foreach($hot_city as $v)
                        @if($v->city_name=="全部")
                    <a href="/new_resource?city=" @if($select_city=='') class="active" @endif>{{$v->city_name}}</a>
                        @else
                            <a href="/new_resource?city={{$v->city_name}}" @if($select_city==$v->city_name) class="active" @endif>{{$v->city_name}}</a>
                        @endif
                            @endforeach
                </dd>
            </dl>
            <dl>
                <dt>品类：</dt>
                <dd>
                    @foreach($category as $v)
                        @if($v->category_name=="全部")
                            <a href="/new_resource?category=&city={{$select_city}}" @if($select_category=='') class="active" @endif>{{$v->category_name}}</a>
                        @else
                            <a href="/new_resource?category={{$v->category_name}}&city={{$select_city}}" @if($select_category==$v->category_name) class="active" @endif>{{$v->category_name}}</a>
                        @endif
                        @endforeach
                </dd>
            </dl>
        </div>
    <form action="/new_resource" method="get">
        <div class="res-bg res-ser">
            <div class="form-inline">
                <div class="form-group">
                    <label for="">品名</label>
                    <input type="hidden" id="category" name="category" value="{{$select_category}}"/>
                    <div class="form-control category">
                        <div class="category-title">
                            全部
                        </div>
                        <i></i>
                        <input type="hidden" name="category" value="">
                    </div>
                    <div class="category-cont"><ul></ul></div>
                </div>
                <div class="form-group">
                    <label for="">钢厂</label>
                    <div class="form-control category">
                        <div class="category-title">
                            全部
                        </div>
                        <i></i>
                        <input type="hidden" name="factory" value="">
                    </div>
                    <div class="category-cont"><ul></ul></div>
                </div>
                <div class="form-group">
                    <label for="">公司名称</label>
                    <input type="text" name="company" class="form-control">
                </div>
                <input type="hidden" id="city" name="city" value="{{$select_city}}"/>

                <div class="form-group">
                    <input type="submit" class="btn-search" value="搜索">
                </div>
                <div class="form-group">
                    <a href="/user_now_resource" class="a-push">上传资源</a>
                </div>
                <div class="clear"></div>
            </div>
        </div>

    </form>
	<div class="res-bg res-cont">
		<div class="cont-ul">
			<ul>
				<li class="active"><a href="javascript:;">全部资源单</a></li>
			</ul>
		</div>
		<div class="cont-box">
			<div class="cont">
                @if($num==1)
                    <div class="shopping-no">
                        <img src="/resource/img/shopping_no.png" alt="">暂时没有找到匹配资源
                    </div>
                @else
				<table class="table">
					<thead>
						<tr>
							<th width="190px">公司名称</th>
							<th width="124px">上传者</th>
							<th width="200px">主营品类</th>
							<th width="190px">主营钢厂</th>
							<th width="210px">资源单描述</th>
							<th width="120px">下载次数</th>
							<th>操作</th>
						</tr>
					</thead>

					<tbody>
                    @foreach($info as $v)
						<tr>
							<td><div class="name">{{$v->company}}</div></td>
							<td><div>{{$v->contact_name}}</div></td>
							<td><div>{{$v->category}}</div></td>
							<td><div>{{$v->factory}}</div></td>
							<td><div class="describe">{{$v->content}}</div></td>
							<td><div><span>{{$v->down_num}}</span></div></td>
							<td class="last">
								<div class="left oper">
                                    @if(session_get(UserEnum::USER_INFO_USER_ID))
									<a href="/look_excel?filename={{str_replace('\\','/',$v->down_address);}}" target="_blank">预览</a>
									<a href="/down_excel?filename={{str_replace('\\','/',$v->down_address);}}" res_id="{{$v->product_id}}">下载</a>
                                    @else
                                        <a href="javascript:;">预览</a>
                                        <a href="javascript:;">下载</a>
                                    <script>
                                        //登录
                                        $('.oper').click(function(){
                                            $('.popup-login').show();
                                            $('.popup').show();
                                        });
                                    </script>
                                    @endif
                                </div>
                                @if(session_get(UserEnum::USER_INFO_SESSION_KEY))
								<div class="left follow Follow" product-id="{{$v->product_id}}">
                                    @if(in_array($v->product_id,$follow_product_id))
									<a href="javascript:;" class="a succ">已关注</a>
                                        @else
                                        <a href="javascript:;" class="a">关注</a>
                                        @endif
								</div>
                                    @else
                                    <div class="left follow">
                                        <a href="javascript:;" class="a">关注</a>
                                    </div>
                                    <script>
                                        //登录
                                        $('.follow').click(function(){
                                            $('.popup-login').show();
                                            $('.popup').show();
                                        });
                                    </script>
                                    @endif
							</td>
						</tr>
                        @endforeach
					</tbody>

				</table> @endif

                {{$info->appends(['city' => $select_city,'category'=>$select_category,'brand'=>$select_brand,'factory'=>$select_factory,'company'=>$select_company])->links()}}
			</div>
			<div class="cont">

			</div>
		</div>
	</div>
</div>

@include('common.shop_foot')
</body>
</html>

